﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FoundationLib.Web.Converters
{
	/// <summary>
	/// This interface provides methods performing conversions during proxy data source property assignments.
	/// </summary>
	public interface IConverter
	{
		/// <summary>
		/// Converts the given input and returns the result.
		/// </summary>
		/// <param name="input">The value to be converted</param>
		/// <param name="direction">The conversion direction</param>
		/// <returns>The result of the conversion</returns>
		/// <exception cref="ArgumentException">The given input is invalid.</exception>
		/// <exception cref="InvalidOperationException">The requested conversion is invalid.</exception>
		object Convert(object input, ConversionDirection direction);

		/// <summary>
		/// Tries to convert the given input and returns the result.
		/// </summary>
		/// <param name="input">The value to be converted</param>
		/// <param name="direction">The conversion direction</param>
		/// <param name="output">The result of the conversion or null if the conversion failed</param>
		/// <returns>True if the conversion was successful, false otherwise</returns>
		bool TryConvert(object input, ConversionDirection direction, out object output);

		/// <summary>
		/// Gets a value indicating whether this converter supports converter options.
		/// </summary>
		bool SupportsOptions
		{
			get;
		}

		/// <summary>
		/// Gets or sets the converter options.
		/// </summary>
		object Options
		{
			get;
			set;
		}
	}
}
